home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / c / flash-0.4.3.lha / flash-0.4.3 / Lib / graphic.h < prev    next >
C/C++ Source or Header  |  1999-02-21  |  4KB  |  123 lines

  1. /////////////////////////////////////////////////////////////
  2. // Flash Plugin and Player
  3. // Copyright (C) 1998 Olivier Debon
  4. // 
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // 
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. // 
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. // 
  19. ///////////////////////////////////////////////////////////////
  20. #ifndef _DISPLAY_H_
  21. #define _DISPLAY_H_
  22.  
  23. #include <X11/Xlib.h>
  24. #include <X11/Xutil.h>
  25. #include <X11/extensions/XShm.h>
  26.  
  27. #include "swf.h"
  28.  
  29. struct SwfPix {
  30.     char *data;
  31.     long bpl;
  32.     long width,height;
  33. };
  34.  
  35. enum FlashEventType {
  36.     FeNone,
  37.     FeMouseMove,
  38.     FeButtonPress,
  39.     FeButtonRelease,
  40.     FeRefresh
  41. };
  42.  
  43. struct FlashEvent {
  44.     FlashEventType     type;
  45.     int         x,y;        // Mouse coordinates, relative to upper-left window corner
  46. };
  47.  
  48. class GraphicDevice {
  49.     // Platform dependent members
  50.     Window             target;    // Target window
  51.     Cursor              buttonCursor;    // Window cursor (a hand if over a button)
  52.     Display            *dpy;        // X11 Display
  53.     GC              gc;        // X11 Graphic context
  54.     Pixmap             canvas;    // Graphic buffer
  55.     XShmSegmentInfo         segInfo;    // Shared memory information
  56.  
  57.     Color             backgroundColor;
  58.     Color             foregroundColor;
  59.     long              handCursorActive;
  60.     int             targetWidth;
  61.     int              targetHeight;
  62.     int             movieWidth;
  63.     int             movieHeight;
  64.     int             zoom;
  65.     unsigned char        *hitTest;
  66.     long             hitTestLookUp[256];
  67.     unsigned long         redMask;
  68.     unsigned long         greenMask;
  69.     unsigned long         blueMask;
  70.  
  71. public:
  72.     long             showMore;    // Used for debugging
  73.  
  74. protected:
  75.     long     clip(long &y, long &start, long &end);
  76.     void     aa(long pixel, long y, long start, long end);
  77.     unsigned long mix(unsigned long c1, unsigned long c2, int weight);
  78.  
  79. public:
  80.     Matrix            *adjust;    // Matrix to fit window (shrink or expand)
  81.  
  82.     // For Direct Graphics
  83.     char             *canvasBuffer;    // A pointer to canvas'memory
  84.     long             bpl;    // Bytes per line
  85.     long             bpp;    // Bytes per pixel
  86.     long             pad;    // Scanline pad in byte
  87.  
  88.     GraphicDevice(Display *d, Window w);    // Platform dependent
  89.     ~GraphicDevice();
  90.  
  91.     void     setBackgroundColor(Color);
  92.     void     setForegroundColor(Color);
  93.     Color     getBackgroundColor();
  94.     Color     getForegroundColor();
  95.     void     setMovieDimension(long width, long height);
  96.     void     setMovieZoom(int zoom);
  97.     void     setMovieOffset(long x, long y);
  98.     void     displayCanvas();
  99.     void     clearCanvas();
  100.     long     getWidth();
  101.     long     getHeight();
  102.     SwfPix     *createSwfPix(long width, long height);
  103.     void     destroySwfPix(SwfPix *pix);
  104.     void     setHandCursor(int active);
  105.     long     (*allocColor)(Color color);
  106.     Color     *getColormap(Color *old, long n, Cxform *cxform);
  107.     void     fillLine(long pixel, long y, long start, long end, int doAa = 0);
  108.     void     fillLine(SwfPix *pix, long xOffset, long yOffset, long y, long start, long end);
  109.     void     fillLine(Gradient *grad, long y, long start, long end);
  110.     void     fillLineRG(Gradient *grad, long y, long start, long end);
  111.     void     fillHitTestLine(unsigned char id, long y, long start, long end);
  112.     void     drawLine(long x1, long y1, long x2, long y2, long width);
  113.     void     synchronize();    // Force drawing of any pending requests
  114.  
  115.     // Hit test methods
  116.     void        resetHitTest();
  117.     unsigned char    registerHitTest(long tagId);
  118.     void        clearHitTest(long tagId);
  119.     long        checkHitTest(long tagId,long x, long y);
  120. };
  121.  
  122. #endif /* _DISPLAY_H_ */
  123.